/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rmiserver;


import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * Main class
 * @author alexxxey
 */
public class BookingTicketServer
{
    public static void main(String []args)
    {                        
        // Регистрация RMI-сервера
        try
        {                        
            System.setSecurityManager(new RMISecurityManager());
            
            TicketServiceImpl tsi = new TicketServiceImpl();

            String addr = args.length == 0 ? "127.0.0.1" : args[0];                                
            Naming.rebind("//"+args[0]+"/TripService", tsi);
                                    
            System.out.println("Booking-Ticket server ready!");          
        }
        catch (Exception ex)
        {
            //Logger.getLogger(TripServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
        }
        
//        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");        
//        
//        ArrayList<Trip> allTrips = DbQuery.findTripsQuery(format.parse("03.01.2013"));
//        allTrips = DbQuery.findTripsQuery(format.parse("03.01.2013"));
//        allTrips = DbQuery.findTripsQuery(format.parse("03.01.2013"));
//        allTrips = DbQuery.findTripsQuery(format.parse("03.01.2013"));
//        for (Trip trip : allTrips)
//        {
//            String info = trip.getTripId() + " "
//                    + trip.getDate() + " "
//                    + trip.getTime() + " "
//                    + trip.getPlacesNum() + " ";
//
//            for (String destStr : trip.getDestinations())
//            {
//                info = info + destStr + " ";
//            }
//
//            System.out.println(info);
//        }
        
//        ArrayList<Integer> places = DbQuery.tripPlacesQuery(1);
//        for (Integer place : places)
//        {
//            System.out.println(place);
//        }
                                           
    }
}
